import request from "@/utils/service"
import type { ResponseData, EmployeeItem, EmployeeList, EmployeeDetail } from "@/types/employee"

// 添加员工
export const addEmployeeAPI = (data: EmployeeItem) => {
  return request.post<any, ResponseData>("/employee", data)
}

/**
 *
 * @param page 页码
 * @param pageSize 每页条数
 * @param name 员工姓名
 * @returns
 */
// 分页查询员工
export const getEmployeeListAPI = (page: number, pageSize: number, name?: string) => {
  return request.get<any, EmployeeList>("/employee/page", {
    params: {
      page,
      pageSize,
      name
    }
  })
}

// 员工状态切换
export const changeEmployeeStatusAPI = (id: number, status: number) => {
  return request.post<any, ResponseData>(`/employee/status/${status}?id=${id}`)
}

// 查询员工详情
export const getEmployeeDetailAPI = (id: number) => {
  return request.get<any, EmployeeDetail>(`/employee/${id}`)
}
// 修改员工信息
export const updateEmployeeInfoAPI = (data: EmployeeItem) => {
  return request.put<any, ResponseData>("/employee", data)
}

// 删除员工
export const deleteEmployeeAPI = (id: number) => {
  return request.delete<any, ResponseData>(`/employee/${id}`)
}
